import request from '@/utils/request'

// 获取所有可借阅的书籍
export const getAllAvaiBooks = () => {
  return request({
    method: 'GET',
    url: '/getAllAvaiBooks'
  })
}

// 分页获取所有书籍
export const getAllBooks = (params) => {
  return request({
    method: 'GET',
    url: '/getAllBooks',
    params
  })
}

// 获取查询下拉菜单
export const getTypeList = () => {
  return request({
    method: 'GET',
    url: '/getTypeList'
  })
}

// 按照条件查询书籍
export const queryBooks = (data) => {
  return request({
    method: 'POST',
    url: '/queryBooks',
    data
  })
}

// 新建书籍提交
export const addBook = (data) => {
  return request({
    method: 'POST',
    url: '/addBook',
    data
  })
}

// 上传图片
export const uploadImage = (data, onUploadProgress) => {
  return request({
    method: 'POST',
    url: '/uploadImage',
    data,
    onUploadProgress
  })
}

// 根据 bookId 获取书本
export const getBook = (params) => {
  return request({
    method: 'GET',
    url: '/getBook',
    params
  })
}

// 强制归还书本
export const giveBackBook = (data) => {
  return request({
    method: 'POST',
    url: '/giveBackBook',
    data
  })
}

// 提交编辑书籍
export const editBook = (data) => {
  return request({
    method: 'POST',
    url: '/editBook',
    data
  })
}
